package com.yanfan.access.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.access.mapper.NjAccessDeviceInfoMapper;
import com.yanfan.access.domain.NjAccessDeviceInfo;
import com.yanfan.access.service.INjAccessDeviceInfoService;

/**
 * 门禁设备信息Service业务层处理
 *
 * @author genluo
 * @date 2024-10-29
 */
@Service
public class NjAccessDeviceInfoServiceImpl extends ServiceImpl<NjAccessDeviceInfoMapper, NjAccessDeviceInfo> implements INjAccessDeviceInfoService {
    @Autowired
    private NjAccessDeviceInfoMapper njAccessDeviceInfoMapper;


    /**
     * 查询门禁设备信息列表
     *
     * @param njAccessDeviceInfo 门禁设备信息
     * @return 门禁设备信息
     */
    @Override
    public List<NjAccessDeviceInfo> queryPageList(NjAccessDeviceInfo njAccessDeviceInfo) {
        LambdaQueryWrapper<NjAccessDeviceInfo> lqw = buildQueryWrapper(njAccessDeviceInfo);
        return njAccessDeviceInfoMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return njAccessDeviceInfoMapper.queryPageList(njAccessDeviceInfo);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<NjAccessDeviceInfo> buildQueryWrapper(NjAccessDeviceInfo bo) {
        LambdaQueryWrapper<NjAccessDeviceInfo> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), NjAccessDeviceInfo::getDeviceName, bo.getDeviceName());
        lqw.like(StringUtils.isNotBlank(bo.getOrgName()), NjAccessDeviceInfo::getOrgName, bo.getOrgName());
        lqw.like(StringUtils.isNotBlank(bo.getLoginName()), NjAccessDeviceInfo::getLoginName, bo.getLoginName());
        lqw.eq(StringUtils.isNotBlank(bo.getSubSystem()), NjAccessDeviceInfo::getSubSystem, bo.getSubSystem());
        return lqw;
    }



}
